// pages/school/school.js
import host from "../../utils/config"
import wxapi from "../../utils/wxapi"

Page({

  /**
   * 页面的初始数据
   */
  data:{
    schools:[],
    values:""
  },

  goSchool_item(e){
    var id=e.currentTarget.dataset.id;
    wx.navigateTo({

    url: './school_item/school_item?schoolid='+id,
  })
  },
  //单项选择
  onClickNav({ detail = {} }) {
    this.setData({
      mainActiveIndex: detail.index || 0,
    });
  },

  onClickItem({ detail = {} }) {
    const activeId = this.data.activeId === detail.id ? null : detail.id;

    this.setData({ activeId });
  },


  share(e){
    wx.downloadFile({
      url: e.currentTarget.dataset.url,
      success: (res) => {
        wx.showShareImageMenu({
          path: res.tempFilePath
        })
        
      },
      fail: (res) => {
        
      },
    })
  },

  
  goSchool:function(e){
    var vv=e.detail.values;
    //comment
    this.setData({
      values:vv,
    })
    //console.log(this.data.values);
  },

  suo: function () {
    //console.log(this.data.values);
    wx.navigateTo({
      url: '/pages/school/school_item/school_item?va='+this.data.values,
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    let a=await wxapi.request(host+"query.php",{table:"school"})
    
    //console.log(a.data);
    
    this.setData({
      //enterpr: a.data.data.enterpr
      schools:a.data.dataList
    })

    console.log(this.data.schools);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})